#pragma once
#include <QDialog>
#include <QPointer>

#include "SDialogTitle.h"
#include "widgets.h"

class WidgetResizer;
class S_WIDGETS_EXPORT SDialog : public QDialog {
  Q_OBJECT

 public:
  enum eButtons {
    button_close = 0,
    button_max,
    button_restore,
    button_expand,
    button_topping
  };

  SDialog(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());

  void setTitle(QString strTitle);
  void setContent(QWidget* content);
  void setEnablePopup(bool enabled);
  void setEnableSetting(bool enabled);
  void addBorder(bool isAddBorder);
  void setEnableDisplay(bool enabled);
  virtual void reject() override;  // 重写虚函数。这里是函数的声明

 protected:
  virtual SDialog* clone(QWidget* parent = nullptr) { return nullptr; }

  void showEvent(QShowEvent* event) override;

 protected
  Q_SLOT : void onPopup();

 protected:
  bool m_bInited = false;
  bool m_addBorder = false;
  QString m_strTitle;
  QColor m_clrBack = QColor("black");
  SDialogTitle* m_title = nullptr;
  WidgetResizer* m_resizer = nullptr;

 private:
  QPointer<SDialog> popup;
};
